 // pages/examine/examine.js
 var app = getApp();
 var com = require('../../common.js');
 Page({
   data: {
     id: ''
   },
   onLoad: function(options) {
     var _this = this
     console.log(json)
     _this.setData({
       id: options.id
     })
     if (options.supplier) {
       _this.setData({
         supplier: options.supplier
       })
     }
   },
   toLinmet(e) {
     var _this = this
     var id = e.currentTarget.id
     if (id == 1) {
       console.log('1', id)
       wx.navigateTo({
         url: '/pages/approve/approve?id=2',
       })
     } else if (id == 2) {
       console.log('2', id)
       wx.clearStorageSync()
       wx.reLaunch({
         url: '/pages/login/login',
       })
     } else if (id == 3) {


      wx.chooseImage({
        success: (res) => {
          console.log(res)
          var tempFilePaths = res.tempFilePaths
          wx.uploadFile({
            url: 'https://server.entergo.top/admin/Index/postGoods', 
            filePath: tempFilePaths[0],
            name: 'files',
            formData: {
              'file': 'files'
            },
            success: function (res) {
              var data = JSON.parse(res.data)
              var list = _this.data.imageList
              list.push(data.name)
              _this.setData({
                imageList:list
              })
              console.log(JSON.parse(res.data));
            }
          })
        },
      })
      //  var info = [{
      //    goodsid:1,
      //    number:3
      //  },{
      //   goodsid:2,
      //   number:1
      // },{
      //   goodsid:3,
      //   number:5
      // }];
      //  var m = JSON.stringify(info)
      // com.link('https://server.entergo.top/admin/Index/onPlaceOrder', {
      //   goodsList :m,
      //   userid:'980302',
      //   message:'测试留言',
      //   userName:'刘威',
      //   telNumber:'17601025873',
      //   provinceName:'北京',
      //   cityName:'北京市',
      //   countyName:'朝阳区',
      //   detailInfo:'百子湾路15号',
      //   count:134
      // }, function(rep) {
      //   console.log(rep)
      // })
       return false
       console.log('3', id)
       wx.navigateTo({
         url: '/pages/contractdetails/contractdetails',
       })
     } else {
       com.link(app.link.downloadFeil + _this.data.supplier + '.st', {}, function(rep) {
         console.log(rep)
         wx.downloadFile({
           url: rep.data.response.file,
           success: function(res) {
             console.log(res)
             wx.saveFile({
               tempFilePath: res.tempFilePath,
               success: function(res) {
                 console.log(res)
                 wx.openDocument({
                   filePath: res.savedFilePath,
                   success(res) {
                     console.log(res)
                   }
                 })
               }
             })
           }
         })
       }, "GET")
     }

   },
   onReady: function() {},
   onShow: function() {
    //  if (wx.getStorageSync('functionId')) {
    //    var _this = this
    //    _this.setData({
    //      id: wx.getStorageSync('functionId')
    //    })
    //    return false
    //  }
     var _this = this
     let url = app.link.appraisal,
       data = {}
     com.link(url, data, function(rep) {
       console.log(rep)
       let i = rep.data.response.response
       wx.setStorageSync('store', i.store)
       if (i.seal) {
         wx.reLaunch({
           url: '/pages/index/index'
         })
         return false;
       }
       if (i.contract) {
         _this.setData({
           id: 4
         })
         return false
       }
       if (i.store > 0 && i.supplier > 0) {
         _this.setData({
           id: 3
         })
         return false
       }
       _this.setData({
         id:1
       })
     },'get')
   },
   onHide: function() {},
   onUnload: function() {},
   onPullDownRefresh: function() {},
   onReachBottom: function() {},
   onShareAppMessage: function() {}
 })